package com.fw;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.fw.annotation.service.HelloService;
import com.fw.annotation.service.UserService;
import com.fw.config.AppConfig;

public class MainApp {
    public static void main(String[] args) {
        //注解方式
        ApplicationContext ac=new AnnotationConfigApplicationContext(AppConfig.class);
        //获取 Bean
        HelloService helloService=ac.getBean(HelloService.class);
        System.out.println("====Spring Annotation测试=====");
        System.out.println(helloService.sayHello());
        System.out.println(helloService.sayHelloTo("Spring Annotation"));
        System.out.println("====Spring Annotation 依赖注入测试=====");
        UserService userService=ac.getBean(UserService.class);
        userService.registerUser("Test1024");
        List<String> users=userService.getAllUsers();
        for(String user:users){
            System.out.println(user);
        }
    }

}
